<template>
    <div>
        <Form inline>
            <FormItem>
                <DatePicker v-model="streetBLTime" type="datetimerange"
                            format="yyyy-MM-dd HH:mm" placeholder="请选择街道统计时间段"
                            style="width: 300px"></DatePicker>
            </FormItem>
            <FormItem>
                <Button :loading="loading.streetBLBtn" type="primary" @click="streetBLAction">查询街道统计项(办理)</Button>
            </FormItem>
        </Form>
        <br>
        <Table :loading="loading.streetBLBtn" :columns="tableColumns.streetBL" :data="tableData.streetBL"></Table>
    </div>
</template>

<script>
import {
  getStreetBL
} from '@/api/statistics'
import { formatDate } from '@/components/dateFormat'
export default {
  data () {
    return {
      streetBLTime: '',
      streetType: '',
      loading: {
        streetBLBtn: false
      },
      tableColumns: {
        streetBL: [
          {
            title: '名称',
            key: 'name',
            align: 'center'
          },
          {
            title: '数量',
            key: 'num',
            align: 'center'
          }
        ]
      },
      tableData: {
        streetBL: []
      }
    }
  },
  methods: {
    streetBLAction () {
      let data = ''
      switch (this.company_code) {
        case 'LA12804' :
          data = 'Heping District,和平区,화평구'
          break
        case 'LA12805' :
          data = 'Shenhe District,瀋河区,沈河区,심하구'
          break
        case 'LA12806' :
          data = 'Tiexi District,鉄西区,铁西区,철서구'
          break
        case 'LA12807' :
          data = 'Huanggu District,皇姑区,황고구'
          break
        case 'LA12808' :
          data = 'Dadong District,大東区,大东区,황고구'
          break
        case 'LA12809' :
          data = 'Hunnan District,渾南区,浑南区,훈남구'
          break
        case 'LA12810' :
          data = 'Yuhong District,于洪区,우홍구'
          break
        case 'LA12811' :
          data = 'Shenbei New District,瀋北新区,沈北新区,심북신구'
          break
        case 'LA12812' :
          data = 'Sujiatun District,蘇家屯区,苏家屯区,소가툰구'
          break
        case 'LA12813' :
          data = 'Liaozhong District,遼中区,辽中区,요중구'
          break
        case 'LA12814' :
          data = 'Xinmin District,新民市,요중구'
          break
        case 'LA12815' :
          data = 'Faku County,法庫県,法库县,법고현'
          break
        case 'LA12816' :
          data = 'Kangping County,康平県,康平县,강평현'
          break
      }
      const startTime = this.streetBLTime[0] !== '' ? formatDate(this.streetBLTime[0], 'yyyy-MM-dd hh:mm:ss') : ''
      const endTime = this.streetBLTime[1] !== '' ? formatDate(this.streetBLTime[1], 'yyyy-MM-dd hh:mm:ss') : ''
      this.loading.streetBLBtn = true
      const param = {
        startTime: startTime,
        endTime: endTime,
        areaName: data
      }
      getStreetBL(param).then(ret => {
        const data = ret.data
        if (data.errcode === 0) {
          this.tableData.streetBL = data.data
          this.loading.streetBLBtn = false
        } else {
          this.error(data)
          this.loading.streetBLBtn = false
        }
      })
    }
  },
  computed: {
    company_code () {
      return this.$store.state.user.severUserInfo.data.company_code
    }
  }
}
</script>

<style scoped>

</style>
